<?php
require_once('global.php');
require_once(D_P.'data/cache/cate.php');
$children = array();
foreach ($catedb as $key => $cate)
{
	$children[$key]=array();
	foreach ($catedb as $c)
	{
		$c['up']==$key && $children[$key][]=$c['cid'];
	}
}
if(!$action)
{
	$root = $db->query("SELECT * FROM cms_category WHERE depth=1 ORDER BY taxis DESC");
	
	require PrintEot('header');
	require PrintEot('tree');
	adminbottom(0);
}
elseif ($action=='showXML')
{
	if($cid){
		$xmlmsg = "<?xml version=\"1.0\" encoding=\"$very[lang]\"?>\n\t<tree>\n";
		$rs = $db->query("SELECT * FROM cms_category WHERE up='$cid' ORDER BY taxis DESC");
		while ($child = $db->fetch_array($rs)) 
		{
			if (empty($login) && !$child['guestview']) continue; //游客不能看
			if (!empty($child['groupids']) && !in_array($login['groupid'], explode(',', $child['groupids']))) continue;
			
			$child['cname'] = htmlspecialchars($child['cname']);
			$xmlmsg.="\t\t<tree text=\"$child[cname]\" action=\"list.php?cid=$child[cid]\" cId=\"$child[cid]\"  ";
			if(count($children[$child['cid']])>0){
				$xmlmsg.="src=\"tree.php?action=showXML&amp;cid=$child[cid]&amp;timestamp=$timestamp\"";
			}
			$xmlmsg.="/>\n";
		}
		$xmlmsg.="\t</tree>";
		header("Content-type: application/xml");
		print $xmlmsg;
	}
}
?>